<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
<%@ include file="/common/plateform/include/common-base.jsp"%>	
  <script src="${ctx}/js/uct/date.js"></script>
  <title>日志查询</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
</head>
<body class="hold-transition ${sysColor} sidebar-mini">
<div class="wrapper">
  <!-- top start -->
  <%@include file="/common/plateform/top.jsp" %>
  <!-- top end -->
  <!-- left start -->
  <%@include file="/common/plateform/left-project.jsp" %>
  <!-- left end-->
  <div class="content-wrapper">
    <!-- Main start -->
<section class="content">
      <div class="row">
        <div class="col-xs-12 ibox">
            <!-- /.box-header -->
			  <div class="box box-info ">
				  <div class="box-header with-border">
					  <h3 class="box-title"><i class="fa fa-search"></i> 日志查询</h3>
					  <div class="box-tools pull-right">
						  <button type="button" class="btn btn-box-tool"
								  data-widget="collapse"><i class="fa fa-minus"></i></button>
						 <%-- <button type="button" class="btn btn-box-tool" data-widget="remove">
							  <i class="fa fa-times"></i></button>--%>
					  </div>
				  </div>
					<div class="box-body">
							<form id="searchFrom" class="form-horizontal" action="javascript:;">
							<input type="hidden" name="doCode" value="logOperationList"/>
							<input type="hidden" name="modelSysname" value="logOperationList"/>
								<div class="form-group">
									<div class="col-sm-2 text-right"><label class="control-label">业务名称：</label>
									</div>
									<div class="col-sm-4">
										<input type="text" class="form-control" name="modelBussiness"  id="modelBussiness" />
									</div>
									<div class="col-sm-2 text-right"><label class="control-label">操作对象：</label>
									</div>
									<div class="col-sm-4">
										<input type="text" class="form-control" name="modelCname"  id="modelCname" />
									</div>
								</div>
								<div class="form-group">
									<%--<div class="col-sm-2 text-right"><label class="control-label">操作类型：</label>
									</div>
									<div class="col-sm-2">
										<input type="text" class="form-control" name="logType"  id="logType" />
									</div>--%>
									<div class="col-sm-2 text-right"><label class="control-label">操作时间：</label>
									</div>
									<div class="col-sm-4">
										<input type="text" class="form-control" name="createdTime"  id="createdTime" class="easyui-datebox" />
									</div>
									<div class="col-sm-2 text-right"><label class="control-label">操作人账号：</label>
									</div>
									<div class="col-sm-4">
										<input type="text" class="form-control" name="createUser"  id="createUser" />
									</div>
								</div>
								<center>
									<div class="box-footer clearfix">
										<button type="button" class="btn btn-success" onclick="getTableData();"><i class="fa fa-search"></i> 查询</button> 
									</div>
								</center>
							</form>
					</div>
			  </div>

				<div class="box box-success">
					<div class="box-header with-border">
						<h3 class="box-title"><i class="fa fa-table"></i> 日志查询列表
						</h3>
						<div class="box-tools pull-right">
							　　　　　　　　
							<button type="button" class="btn btn-box-tool"
									data-widget="collapse"><i class="fa fa-minus"></i>
							</button>
							<%--<button type="button" class="btn btn-box-tool" data-widget="remove">
                                <i class="fa fa-times"></i></button>--%>
						</div>
					</div>
					<div class="box-body" id="dataList-body">
					  <table id="example" class="table table-bordered table-hover" >
						<thead class="bg-success">
						<tr>
						  <th>所属系统</th>
						  <th>业务名称</th>
						  <th>操作表</th>
						  <th>操作类型</th>
						  <th>操作时间</th>
						  <th>操作人账号</th>
						  <th>操作IP或域名</th>
						  <th>操作</th>
						</tr>
						</thead>
						<tbody id="myList">
						</tbody>
					  </table>
						<center>
							  <ul id="pageList"></ul>
						</center>
					</div>
            	</div>
        </div>
      </div>
    </section>
    
    <div class="modal fade" id="my_modal_detail" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" title="查看审计日志详细">
	<div class="modal-dialog" style="width:1000px;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
						<h4 class="modal-title"><font color="red">日志详情查看</font>&nbsp;</h4>
					</div>
					<div class="modal-body">
					 <center id="itemInfo_center"></center>
						<div class="panel">
							<div class="panel-body">
								<table id="example_detail" class="table table-bordered table-hover" >
									<thead class="bg-success">
									<tr>
										<th class="w150">属性（字段）</th>
										<th class="w200">属性名称</th>
										<%--<th>旧值</th>--%>
										<th>新值</th>
									</tr>
									</thead>
									<tbody id="detailList">
									</tbody>
								</table>
							</div>
						</div>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>  
    
    <!-- Main end -->
    	<script type="text/template" id="dataList">
	  		<? for ( var i = 0; i < rows.length; i++) {?>
				<tr>
					<td style="display:none;"><?=rows[i].logId?></td>
					<td><?=rows[i].modelSysname?></td>
					<td><?=rows[i].modelBussiness?></td>
					<td><?=rows[i].modelCname?></td>
					<td><?=rows[i].logType?></td>
					<td><?=getSmpFormatDateByLong(rows[i].createdTime,true)?></td>
					<td><?=rows[i].createUser?></td>
					<td><?=rows[i].logIp?></td>
					<td><button class="btn btn-xs btn-success" onclick="view('<?=rows[i].logId?>')">查看详情</button></td>
				</tr>
     		<?}?>
	</script>

<script type="text/template" id="detail_List">
	  		<? for ( var i = 0; i < rows.length; i++) {?>
				<tr>
					<td><?=rows[i].propertyEname?></td>
					<td><?=rows[i].propertyName?></td>
					<td><?=rows[i].propertyValue?></td>
				</tr>
     		<?}?>
	</script>
<script type="text/template" id="itemInfo">
查看审计日志详细内容&nbsp;&nbsp; 业务名称:<?=ddd.modelBussiness?>&nbsp;&nbsp; <font color=red><?=ddd.logType?></font>
</script>	
<script>
var clickMenu= 'log-operation-list';
var id;
var defSysEname = strUtil.doNull(strUtil.getLocalStorage("sysEname"), "");
$("#searchFrom").find("input[name='modelSysname']").val(defSysEname);

$(function () {
	getTableData();
	$('#example tbody').on('click','tr', function (e) {
	     if ( $(this).hasClass('selected') ) {
	            //$(this).removeClass('selected');
	        }
	        else {
	            $('tr.selected').removeClass('selected');
	            $(this).addClass('selected');
	        }
	     id = $('tr.selected td').eq(0).html();
	   //  console.log($('tr.selected td').eq(1).html())
	} );
  });
  
//设置模态框隐藏事件钩子  
$( '#my_modal' ).on( 'hide.bs.modal' ,function(e){  
	cleanData('userFormData');
}); 

//设置模态框隐藏事件钩子  
$( '#my_modal' ).on( 'show.bs.modal' ,function(e){  
	$.ajax({
	    type:'get',
	    url:'${ctx}/sendPage/token?token=true',
	    dataType:'json',
	    success: function(myData){
	    	//console.log(myData);
			 $('#formToken').val(myData);
	  	}
	});	
}); 

function cleanData(id){
	$(':input','#'+id)  
	 .not(':button, :submit, :reset, :hidden')  
	 .val('')  
	 //.removeAttr('checked')  
	 .removeAttr('selected'); 
}

function getTableData(){
	deleteAllRow('example');
	var utrlss="${ctx}/trans/list/?doCode=logOperationList";
	$.ajax({
		   type:'get',
		   url:utrlss,
		   data:$('#searchForm').serialize()+getCurrentPage(utrlss+"?"+$('#searchForm').serialize(),15),
		   dataType:'json',
		   success: function(myData){
			var data = baidu.template('dataList',eval(myData));
			// console.log("------------------->",data);
			$("#myList").html(data);
			  var option= {
					   ele:$("#pageList")[0],
					   total:myData.total,
					   fn:getTableData,
					   url:utrlss+"?"+$('#searchForm').serialize()
				   }
			generatePages(option);
		   }
		});	
  }

function deleteAllRow(tableId){
	var tb = document.getElementById(tableId);
	if(tb){
	     var rowNum=tb.rows.length;
	     for (var i=1;i<rowNum;i++){
	         tb.deleteRow(i);
	         rowNum=rowNum-1;
	         i=i-1;
	     }
     }
}

function view(logId){
	//window.location="${page_admin}/audit/log-operation-view?logId="+logId;
	$('#my_modal_detail').modal('show');
	deleteAllRow('example_detail');
	var utrlss="${ctx}/trans/info/?doCode=viewLogDetail&logId="+logId;
	$.ajax({
		   type:'get',
		   url:utrlss,//user_search_url,
		   data:$('#searchForm').serialize(),
		   dataType:'json',
		   success: function(myData){
			   // console.log(myData);
			var test ={};
			test.ddd=myData.item;
			//var data2 = baidu.template('itemInfo',test);
			//$("#itemInfo_center").html(data2);
			var data = baidu.template('detail_List',myData);  
			// console.log(myData);
			$("#detailList").html(data);
		   }
	});	
}

function cannel(modalId){
	$('#'+modalId).modal('hide');
}

function refresh(){
    //window.location.reload();
	getTableData();
}
</script>




  </div>
  <!-- /.content-wrapper -->
  
  <!-- foot start -->
       
 <%@include file="/common/plateform/foot.jsp" %>
</div>    

</body>

</html>
